#ifndef TELNETWINDOW_H
#define TELNETWINDOW_H

#include <QMainWindow>
#include <QDialog>
#include <QAbstractSocket>

class QLineEdit;
class QtTelnet;

namespace Ui {
class TelnetWindow;
}

class TelnetWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit TelnetWindow(QWidget *parent = nullptr);
    ~TelnetWindow();

private slots:
    void telnetMessage(const QString &msg);
    void telnetLoginRequired();
    void telnetLoginFailed();
    void telnetLoggedOut();
    void telnetLoggedIn();
    void telnetConnectionError(QAbstractSocket::SocketError error);

    void deleteCharOrLogout();
    void suspend();
    void kill();
    void lineReturnPressed();

    void on_connectBtn_clicked();
    void on_loadBtn_clicked();
    void on_execBtn_clicked();
    void on_pauseBtn_clicked();
    void on_stopBtn_clicked();

    void execScript();

private:
    QString stripCR(const QString &msg);

protected:
    void resizeEvent(QResizeEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);

private:
    Ui::TelnetWindow *ui;
    QtTelnet *telnet;
    QTimer *script_timer;
    QByteArrayList scripts;
};

class LoginDialog : public QDialog
{
public:
    LoginDialog(QWidget *parent = nullptr);
    ~LoginDialog();

    QString login() const;
    QString password() const;


private:
    QLineEdit *lle, *ple;
};

#endif // TELNETWINDOW_H
